import request from '../index';
import fileDownload from 'js-file-download';

const apiUrl = '/api-server';
const baseUrl = '/base-server';
const marketUrl = '/marketing-server';


// 优惠券明细导出
export const EXPORT_ENTITY = `${marketUrl}/coupon/exportEntity`;
// 导出优惠券活动发放记录
export const EXPORT_TASKRECORD = `${marketUrl}/coupon/exportTaskRecord`;
//导出用户活动发放记录
export const EXPORT_ACTIVITYRECORD = `${marketUrl}/userActivity/exportActivityRecord`;
//导出组团充电活动成团记录
export const EXPORT_ACTIVITYTEAM = `${marketUrl}/userActivity/exportTeam`;
//用户标签导出
export const EXPORT_LABELUSERLIST = `${baseUrl}/label/exportLabelList`;
//导出单个标签站点信息列表
export const EXPORT_LABELSTATIONLIST = `${baseUrl}/label/exportPageQueryLabelStationList`;


// 查询充电卡信息列表
export const URL_PAGINGSTATIONACTIVITY = `${marketUrl}/stationActivity/pagingStationActivity`;
export const pagingStationActivity = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/stationActivity/pagingStationActivity`,
    params: { form: params, pages: pages },
  });
};

//终止电站活动
export const terminateStationActivity = (params: any) => {
  return request({
    url: `${marketUrl}/stationActivity/terminate`,
    params: { form: params, successMsg: '2' },
  });
};

//保存电站活动
export const stationActivitySave = (params: any) => {
  return request({
    url: `${marketUrl}/stationActivity/save`,
    params: { form: params, successMsg: '1' },
  });
};

//更新电站活动
export const stationActivityUpdate = (params: any) => {
  return request({
    url: `${marketUrl}/stationActivity/update`,
    params: { form: params, successMsg: '1' },
  });
};

//获取电站活动详情
export const stationActivityDetail = (params: any) => {
  return request({
    url: `${marketUrl}/stationActivity/getById`,
    params: { form: params },
  });
};

//-----------广告管理---------------------------------
// 查询充电卡信息列表
export const URL_PAGINGADVERTISEMENT = `${marketUrl}/advert/pagingAdvertisement`;
export const pagingAdvertisement = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/advert/pagingAdvertisement`,
    params: { form: params, pages: pages },
  });
};

//广告手动上下架
export const advertGround = (params: any) => {
  return request({
    url: `${marketUrl}/advert/ground`,
    params: { form: params },
  });
};

//删除广告
export const advertDelete = (params: any) => {
  return request({
    url: `${marketUrl}/advert/deleteById`,
    params: { form: params },
  });
};

//新增广告信息
export const saveAdvertisement = (params: any) => {
  return request({
    url: `${marketUrl}/advert/saveAdvertisement`,
    params: { form: params },
  });
};

//修改广告信息
export const updateAdvertisement = (params: any) => {
  return request({
    url: `${marketUrl}/advert/updateAdvertisement`,
    params: { form: params },
  });
};

//获取广告详情
export const getAdvertisement = (params: any) => {
  return request({
    url: `${marketUrl}/advert/getById`,
    params: { form: params },
  });
};


//查询广告可配置跳转的用户活动
export const queryAdUserActivity = (params?: any) => {
  return request({
    url: `${marketUrl}/userActivity/queryAdUserActivity`,
    params: { form: params || null },
  });
};

//------------------------------------------------------
// 查询标签信息列表
export const URL_QUERYLABELLIST = `${baseUrl}/label/queryLabelList`;
export const queryLabelList = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/label/queryLabelList`,
    params: { form: params, pages: pages },
  });
};

//删除标签
export const deleteLabel = (params: any) => {
  return request({
    url: `${baseUrl}/label/deleteLabel`,
    params: { form: params },
  });
};

//标签账号导入
export const URL_UPLOADUSERS = `/api${baseUrl}/label/labelImport`;


//查询单个标签用户信息列表-列表页面
export const queryUserLabelList = (params: any, pages: any) => {
  params = { ...params, ...pages }
  return request({
    url: `${baseUrl}/label/queryUserLabelList`,
    params: { form: params, pages: pages },
  });
};


//查询单个标签用户信息列表-新增页面
export const queryUserList = (params: any, pages: any) => {
  params = { ...params, ...pages };
  return request({
    url: `${baseUrl}/user/queryUserList`,
    params: { form: params, pages: pages },
  });
};

//查询单个标签站点信息列表
export const queryLabelStationList = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/label/pageQueryLabelStationList`,
    params: { form: params, pages: pages },
  });
};

//新增标签
export const addLabel = (params: any) => {
  return request({
    url: `${baseUrl}/label/addLabel`,
    params: { form: params },
  });
};

//修改标签
export const updateLabel = (params: any) => {
  return request({
    url: `${baseUrl}/label/updateLabel`,
    params: { form: params },
  });
};

//查询标签详情接口
export const queryLabelDetail = (params: any) => {
  return request({
    url: `${baseUrl}/label/queryLabelDetail`,
    params: { form: params },
  });
};

//-优惠券------------------------------------------------------------
// 分页查询优惠券活动
export const URL_PAGINGACTIVITY = `${marketUrl}/coupon/pagingActivity`;
export const pagingActivity = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/coupon/pagingActivity`,
    params: { form: params, pages: pages },
  });
};

// 保存优惠券活动
export const saveActivity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/saveActivity`,
    params: { form: params },
  });
};

// 更新优惠券活动
export const updateActivity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/updateActivity`,
    params: { form: params },
  });
};

// 获取优惠券活动详情
export const getActivityById = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/getActivityById`,
    params: { form: params },
  });
};

// 优惠券活动成本核算
export const costingActivity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/costingActivity`,
    params: { form: params },
  });
};

// 作废优惠券活动
export const voidedActivity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/voidedActivity`,
    params: { form: params },
  });
};

//查询优惠券活动下拉列表
export const queryActivity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/queryActivity`,
    params: { form: params },
  });
};

//保存优惠券活动发放任务
export const saveTask = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/saveTask`,
    params: { form: params },
  });
};

//更新优惠券活动发放任务
export const updateTask = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/updateTask`,
    params: { form: params },
  });
};

//获取优惠券活动发放任务详情
export const getTaskById = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/getTaskById`,
    params: { form: params },
  });
};

// 分页查询优惠券实体-发放明细
export const URL_PAGINGENTITY = `${marketUrl}//coupon/pagingEntity`;
export const pagingEntity = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/coupon/pagingEntity`,
    params: { form: params, pages: pages },
  });
};

//手动核销优惠券实体
export const writeOffEntity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/writeOffEntity`,
    params: { form: params },
  });
};

//作废优惠券实体
export const voidedEntity = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/voidedEntity`,
    params: { form: params },
  });
};

//批量作废优惠券实体
export const voidedEntityBatch = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/voidedEntityBatch`,
    params: { form: params },
  });
};

//手动发放记录----------------------------
// 分页查询优惠券活动发放任务
export const URL_PAGINGTASK = `${marketUrl}/coupon/pagingTask`;
export const pagingTask = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/coupon/pagingTask`,
    params: { form: params, pages: pages },
  });
};

//终止优惠券活动发放任务
export const terminateTask = (params: any) => {
  return request({
    url: `${marketUrl}/coupon/terminateTask`,
    params: { form: params },
  });
};

// 分页查询优惠券活动发放记录
export const URL_PAGINGTASKRECORD = `${marketUrl}/coupon/pagingTaskRecord`;
export const pagingTaskRecord = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/coupon/pagingTaskRecord`,
    params: { form: params, pages: pages },
  });
};

//---------------------------------------------------
// 分页查询用户活动
export const URL_PAGINGUSERACTIVITY = `${marketUrl}/userActivity/pagingUserActivity`;
export const pagingUserActivity = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/userActivity/pagingUserActivity`,
    params: { form: params, pages: pages },
  });
};

//终止用户活动
export const terminateUser = (params: any) => {
  return request({
    url: `${marketUrl}/userActivity/terminate`,
    params: { form: params },
  });
};

//保存用户活动
export const saveUserActivity = (params: any) => {
  return request({
    url: `${marketUrl}/userActivity/saveActivity`,
    params: { form: params },
  });
};

//更新用户活动
export const updateUserActivity = (params: any) => {
  return request({
    url: `${marketUrl}/userActivity/updateActivity`,
    params: { form: params },
  });
};

//获取用户活动详情
export const getUserActivityById = (params: any) => {
  return request({
    url: `${marketUrl}/userActivity/getActivityById`,
    params: { form: params },
  });
};

// 分页查询用户活动发放记录
export const URL_PAGINGACTIVITYRECORD = `${marketUrl}/userActivity/pagingActivityRecord`;
export const pagingActivityRecord = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/userActivity/pagingActivityRecord`,
    params: { form: params, pages: pages },
  });
};

// 分页查询用户活动发放记录
export const URL_PAGINGTEAM = `${marketUrl}/userActivity/pagingTeam`;
export const pagingTeam = (params: any, pages: any) => {
  return request({
    url: `${marketUrl}/userActivity/pagingTeam`,
    params: { form: params, pages: pages },
  });
};

//下载活动二维码
export const downloadQrCode = (params: any) => {
  request({
    url: `${marketUrl}/userActivity/downloadQrCode`,
    responseType: 'blob',
    params: { form: params.id, export: true },
  }).then((res: any) => {
    fileDownload(res, `${params.name}.png`);
  });
};

//----------------------------------------
// 分页查询通知信息
export const URL_PAGINGNOTICE = `${apiUrl}/notice/pagingNotice`;
export const pagingNotice = (params: any, pages: any) => {
  return request({
    url: `${apiUrl}/notice/pagingNotice`,
    params: { form: params, pages: pages },
  });
};

//删除通知信息
export const deleteNoticeById = (params: any) => {
  return request({
    url: `${apiUrl}/notice/deleteById`,
    params: { form: params },
  });
};

//保存通知
export const saveNotice = (params: any) => {
  return request({
    url: `${apiUrl}/notice/save`,
    params: { form: params },
  });
};

//更新通知信息
export const updateNotice = (params: any) => {
  return request({
    url: `${apiUrl}/notice/update`,
    params: { form: params },
  });
};

//查询通知信息详细
export const queryNoticeDetail = (params: any) => {
  return request({
    url: `${apiUrl}/notice/queryNoticeDetail`,
    params: { form: params },
  });
};

//------------------------------------------------------
// 分页查询问题分类
export const URL_PAGINGQUESTIONCLASS = `${apiUrl}/question/pagingQuestionClass`;
export const pagingQuestionClass = (params: any, pages: any) => {
  return request({
    url: `${apiUrl}/question/pagingQuestionClass`,
    params: { form: params, pages: pages },
  });
};

//删除问题分类
export const deleteQuestionById = (params: any) => {
  return request({
    url: `${apiUrl}/question/deleteById`,
    params: { form: params },
  });
};

//保存问题分类
export const saveQuestion = (params: any) => {
  return request({
    url: `${apiUrl}/question/save`,
    params: { form: params },
  });
};

//更新问题分类
export const updateQuestion = (params: any) => {
  return request({
    url: `${apiUrl}/question/update`,
    params: { form: params },
  });
};

// 分页查询问题
export const URL_PAGINGQUESTION = `${apiUrl}/problem/pagingQuestion`;
export const pagingQuestion = (params: any, pages: any) => {
  return request({
    url: `${apiUrl}/problem/pagingQuestion`,
    params: { form: params, pages: pages },
  });
};

//删除问题
export const deleteProblemById = (params: any) => {
  return request({
    url: `${apiUrl}/problem/deleteById`,
    params: { form: params },
  });
};

//问题上下架
export const groundProblem = (params: any) => {
  return request({
    url: `${apiUrl}/problem/ground`,
    params: { form: params },
  });
};

//新增问题
export const saveProblem = (params: any) => {
  return request({
    url: `${apiUrl}/problem/save`,
    params: { form: params },
  });
};

//更新问题
export const updateProblem = (params: any) => {
  return request({
    url: `${apiUrl}/problem/update`,
    params: { form: params },
  });
};

//查看问题详情
export const getProblemDetail = (params: any) => {
  return request({
    url: `${apiUrl}/problem/detail`,
    params: { form: params },
  });
};